package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domain.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import javax.ws.rs.Path;

/**
 * @author げっしょく
 * @date 2021/11/5
 */
public interface LogMapper extends BaseMapper<Log> {

    //查询当日注册人数
    @Select("SELECT COUNT(*) from tb_log WHERE type = '0102' AND log_time = #{dayTime}")
    Integer getEnrollment(@Param("dayTime") String dayTime);

    //查询当日活跃人数
    @Select("SELECT COUNT(DISTINCT user_id) count FROM tb_log WHERE log_time = #{dayTime}")
    Integer getActiveCount(@Param("dayTime") String dayTime);

    //查询次日留存人数
    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE log_time = #{dayTime} AND user_id in (\n" +
            "SELECT user_id FROM tb_log WHERE type = '0102' AND log_time = #{yesterDay})")
    Integer getKeepCount(@Param("dayTime") String dayTime, @Param("yesterDay") String yesterDay);

    //查询当日登陆人数
    @Select("SELECT COUNT(DISTINCT user_id) count FROM tb_log WHERE type = '0101' AND log_time = #{dayTime}")
    Integer getloginCount(@Param("dayTime") String dayTime);

}
